package com.example.secondhandsysapi.Mapper;

import com.example.secondhandsysapi.Entity.ShopCartInfo;
import com.example.secondhandsysapi.Vo.ShopCartGoodsInfo;
import org.apache.ibatis.annotations.Delete;
import org.apache.ibatis.annotations.Mapper;
import org.apache.ibatis.annotations.Param;
import org.apache.ibatis.annotations.Select;

import java.util.List;

@Mapper
public interface ShopCartInfoMapper {

    @Select("select card_id,count,goods_info.goods_id,goods_name,goods_price,goods_image,goods_info.user_id from shop_cart_info join goods_info where shop_cart_info.goods_id = goods_info.goods_id  and shop_cart_info.user_id=#{user_id}")
    List<ShopCartGoodsInfo> getShopCartInfo1(@Param("user_id") Integer user_id);

    @Delete(" delete FROM shop_cart_info WHERE user_id=#{user_id} and goods_id = #{goods_id} ")
    Integer deleteShopCartGoodsInfo(@Param("user_id") Integer user_id,@Param("goods_id") Integer id);

    //从商品详情页添加购物车
    @Select("INSERT INTO shop_cart_info (user_id, goods_id, count, create_date)  \n" +
            "VALUES ( #{user_id}, #{goods_id}, #{count}, NOW())")
    Integer getShopCartInfo(@Param("user_id") Integer user_id, @Param("goods_id") Integer goods_id,@Param("count") Integer count);

}